var http = require('http');
var fs = require('fs');
var path = require('path');

var server = http.createServer(function (req, res) {
    var method = req.method;
    if (method === "GET") {
        var fileName = path.resolve(__dirname, 'data.txt');
        // fs.readFile(fileName, function (req, data) {
        //     res.end(data);
        // });
        var stream = fs.createReadStream(fileName);
        stream.pipe(res);
    }
});
server.listen(3000);